package com.orhon.smartcampus.modules.baseinfo.entity;

import com.orhon.smartcampus.modules.base.entity.Schools;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "baseinfo_timetable", schema = "smartcloud", catalog = "")
public class Timetable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    
    @Column(name = "name", nullable = true)
    private String name;
    
    @Column(name = "is_current", nullable = false)
    private Integer isCurrent;
    
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    
    @Column(name = "created_by", nullable = true)
    private Integer createdBy;
    
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    
    @Column(name = "updated_by", nullable = true)
    private Integer updatedBy;
    
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;
    
    @OneToMany
    @JoinColumn(name = "timetable_id", referencedColumnName = "id")
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action=NotFoundAction.IGNORE)
    private List<TimetableItem> items;

    @ManyToOne
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action=NotFoundAction.IGNORE)
    private Schools baseSchoolsBySchoolId;


}
